<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script> -->
     <!-- 引入Vue 全局注册一个名为Vue的构造函数 -->
 <script src="./js/vue.js"></script>
    <title>列表</title>
</head>
<!-- 案例：列表过滤 实现搜索框功能的实现 -->
<body>
    <div id="root">
 
   <ul>
    <li v-for="p in persons" :key="p.id">{{p.name}}--{{p.sex}}--{{p.age}},<input type="text"></li>
   </ul>
  <button @click="updateData">更新第一条数据</button>
    </div>
    <script>
      var vm= new Vue({
      el: '#root',
      data: {
    
        persons:[
            {"id":001,"name":"李彤康",'age':22,'sex':'男'},
            {"id":002,"name":"李如萍",'age':19,'sex':'女'},
            {"id":003,"name":"冯雅琪",'age':23,'sex':'女'},
            {"id":004,"name":"程丽娜",'age':25,'sex':'女'}
        ],
     
      },
      methods: {
        updateData(){
            //this.persons[0].name="ltk";
         // this.persons[0]= {"id":002,"name":"李彤康1",'age':23,'sex':'男'};
          this.persons.splice(0,1,{"id":002,"name":"李彤康1",'age':23,'sex':'男'})
          //this.$forceUpdate();
        }
      },
    }
      )
    </script>
</body>
</html>